package com.fita.scheduler.dao;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Update;
import com.demo2do.core.persistence.annotation.Variable;
import com.fita.scheduler.entity.DistributionRewardRecord;
import com.fita.scheduler.entity.UserWallet;

/**
 * @description:
 * @author: 11200
 * @date: 2019/8/1
 */
@Dao
public interface DistributionRewardRecordDao {

    @Update("UPDATE distribution_reward_record SET status  = 'CANCEL' WHERE id = :id ")
    void cancel(@Variable("id") Long distributionRewardRecordId);

    @Query("SELECT id, amount, rate, current_user_wallet_amount, create_time, status, target_user_wallet_id FROM distribution_reward_record WHERE is_disabled = 0 AND id = :id ")
    DistributionRewardRecord load(@Variable("id") Long id);

    @Update("UPDATE distribution_reward_record SET status  = 'CONSUMED', current_user_wallet_amount = :currentUserWalletAmount WHERE id = :id ")
    void consume(DistributionRewardRecord distributionRewardRecord);
}
